package racing.bot;

import java.util.Random;

import racing.car.RacingCar;
import racing.car.RacingCarFactory;
import racing.rule.RPS;

/**
 * A robot class for playing with bot mode.
 * 
 * @author Sarathit Sangtaweep 5510546182 
 * @author Veerapat Teeravipark 5510547022
 * @version 2013
 */
public class Bot {
	/**Attribute for randomizing the value.*/
	Random random;
	
	/**
	 * Constructor of the class.
	 */
	public Bot(){
		random = new Random();
	}
	
	/**
	 * Random a RacingCar for the bot.
	 * @return bot's RacingCar.
	 */
	public RacingCar randomCar(){
		RacingCarFactory carFactory = RacingCarFactory.getInstance();
		String[] allCar = carFactory.getAllCar();
		int min = 0, max = allCar.length-1;
		int carNumber = random.nextInt(max - min + 1) + min;
		return carFactory.createCar(allCar[carNumber]);
	}
	
	/**
	 * Random the RPS for the bot. (Rock, Paper, Scissors)
	 * @return bot's RPS.
	 */
	public RPS randomPlayRPS(){
		int min = 1, max = 3;
		int rps = random.nextInt(max - min + 1) + min;
		if(rps == 1) return RPS.ROCK;
		else if (rps == 2) return RPS.PAPER;
		else return RPS.SCISSORS;
	}
	
	/**
	 * Random the number from 1 to 6.
	 * @return the random number from 1 to 6.
	 */
	public int randomPlayDice(){
		int min = 1, max = 6;
		return random.nextInt(max - min + 1) + min;
	}

}
